# -*- coding: utf-8 -*-
import scrapy
from ..items import PhotoItem

class CarPhotoSpider(scrapy.Spider):
    name = 'car_photo'
    allowed_domains = ['car.autohome.com.cn']
    start_urls = ['https://car.autohome.com.cn/pic/series/65.html#pvareaid=3454438']

    def parse(self, response):
        uiboxs=response.xpath('//div[@class="uibox"]')[1:]
        for uibox in uiboxs:
            title=uibox.xpath('./div[@class="uibox-title"]/a/text()').get()
            img_url=uibox.xpath('./div[contains(@class,"uibox-con")]//li//img/@src').getall()
            img_url=list(map(lambda a:'https:'+a,img_url))
            item=PhotoItem(title=title,image_urls=img_url)
            yield item
